Skip to content

Add environment variable support for automation#8515

Merged
alexr00 merged 1 commit intomainfrom
alexr00/shrill-quokka
Feb 16, 2026
Merged

Add environment variable support for automation#8515
alexr00 merged 1 commit intomainfrom
alexr00/shrill-quokka

Conversation

@alexr00
Copy link
Member

@alexr00 alexr00 commented Feb 13, 2026

No description provided.

@alexr00 alexr00 self-assigned this Feb 13, 2026
@alexr00 alexr00 marked this pull request as ready for review February 16, 2026 16:45
Copilot AI review requested due to automatic review settings February 16, 2026 16:45
@alexr00 alexr00 enabled auto-merge (squash) February 16, 2026 16:46
@vs-code-engineering vs-code-engineering bot added this to the February 2026 milestone Feb 16, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for authenticating the extension to GitHub.com using an environment-provided token, intended to enable non-interactive/automation scenarios without relying on VS Code’s authentication session.

Changes:

  • Introduces tryInitializeFromEnvironmentToken() to create a GitHub client from process.env.GITHUB_OAUTH_TOKEN.
  • Hooks env-token initialization into the start of initialize() so it takes precedence over VS Code auth sessions.
Comments suppressed due to low confidence (3)

src/github/credentials.ts:171

  • New auth behavior (env-token initialization + precedence over VS Code auth) is not covered by tests. Since this impacts core authentication and session/scopes upgrade flows, add unit tests to cover at least: env token present/absent, env token ignored when forcing a new session, and required-scope upgrade interactions.
		const envResult = await this.tryInitializeFromEnvironmentToken(authProviderId);
		if (envResult) {
			return envResult;
		}

src/github/credentials.ts:171

  • initialize() now attempts env-token auth unconditionally, which means explicit interactive flows (e.g. forceNewSession, createIfNone: true) can no longer force a VS Code authentication session. This can prevent users from switching accounts or re-consenting scopes unless they manually unset the env var. Consider only using the env token when getAuthSessionOptions.silent is true (or when neither forceNewSession nor createIfNone is set), or add an explicit opt-out flag for env-token auth.
		const envResult = await this.tryInitializeFromEnvironmentToken(authProviderId);
		if (envResult) {
			return envResult;
		}

src/github/credentials.ts:171

  • Env-token initialization bypasses the scopes/requireScopes logic used for upgrading sessions (e.g. getHubEnsureAdditionalScopes() calls initialize(..., SCOPES_WITH_ADDITIONAL, true)). With the current early-return, the code will report success without ensuring/recording the requested scopes, which can cause repeated upgrade attempts or later authorization failures. Consider plumbing scopes/requireScopes into tryInitializeFromEnvironmentToken and either (a) validate the token has the needed scopes or (b) explicitly set the store’s effective scopes to the requested set when env auth is used.
		const envResult = await this.tryInitializeFromEnvironmentToken(authProviderId);
		if (envResult) {
			return envResult;
		}

@alexr00 alexr00 merged commit 7841c9d into main Feb 16, 2026
12 checks passed
@alexr00 alexr00 deleted the alexr00/shrill-quokka branch February 16, 2026 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants